FROM mongo:3
RUN useradd -s /bin/bash -g root -u 1002 yarn

ADD init.sh /init.sh
ADD ./dump /
ADD jdk1.8.0_131.tar.gz /opt
ADD ./target/account-mongo-service.jar /app/

ENV JAVA_HOME /opt/jdk1.8.0_131

RUN \
 ln -s /opt/jdk1.8.0_131/bin/java /usr/bin/java && \
 mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
    echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" >/etc/apt/sources.list && \
    echo "deb http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list && \
    echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list && \
    echo "deb-src http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list &&\
 chmod +x /init.sh && \
 apt-get update && apt-get dist-upgrade -y && \
 apt-get install psmisc -y -q && \
 apt-get autoremove -y && apt-get clean && \
 rm -rf /var/cache/* && rm -rf /var/lib/apt/lists/*

EXPOSE 7777

ENTRYPOINT ["/init.sh"]